package com.chaucer.dynamicdemo.config;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @Description TODO
 * @Author Chaucer
 * @Date 2021/9/2 16:19
 */
public class DynamicDataSource extends AbstractRoutingDataSource {
    RouteChoose routeChoose;
    public DynamicDataSource(RouteChoose routeChoose) {
        this.routeChoose = routeChoose;
    }

    @Override
    protected Object determineCurrentLookupKey() {
        return DynamicThreadLocal.get();
    }
}